<?php 
//update_option('siteurl','https://localhost:4430/bigckool/');
//update_option('home','https://localhost:4430/bigckool/');

//t(get_option('siteurl'));

function callback($buffer) {
  // modify buffer here, and then return the updated code
  $output = ob_get_contents ();
  t($output);
  return preg_replace('/http:\/\//i', 'https://', $buffer);
  
}

function buffer_start() { ob_start("callback"); }

function buffer_end() { ob_end_flush(); }



function register_my_menu() {
  register_nav_menu('header-menu',__( 'Header Menu' ));
}
function t($data,$exit=1) {
	echo '<pre style="text-align:left;">';
	print_r($data);
	echo '</pre>';
	if($exit)exit;
}
add_theme_support( 'post-thumbnails' );
function is_category_in($catname,$cats){
	foreach($cats as $k=>$v)
		if($v->name==$catname)return true;
	return false;
}
function custom_init(){
	header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');
	//start session
 	if(!session_id()) {
        session_start();
    }
}
add_action('init', 'custom_init');
//=================== enqueue style =========
function convert_secure_link($content)
{
	return preg_replace('/http:\/\//i', 'https://', $content);
}
add_filter('the_content', 'convert_secure_link');

function script_include(){
	wp_enqueue_script('mycommon', get_template_directory_uri() . '/js/mycommon.js');	
	wp_enqueue_script('bigc', get_template_directory_uri() .'/js/bigc.js',array('jquery-ui-core'));
	wp_enqueue_script('myjqueryui', 'https://code.jquery.com/ui/1.10.2/jquery-ui.js',array('jquery'));
	wp_enqueue_script('jquery.xdomainrequest', get_template_directory_uri() .'/js/jquery.xdomainrequest.min.js',array('jquery'));
	if(is_category() || is_search()){
		wp_enqueue_script('jquery.mCustomScrollbar.concat.min', get_template_directory_uri() .'/js/jquery.mCustomScrollbar.concat.min.js',array('jquery'));
		wp_enqueue_script('jquery.watermark', get_template_directory_uri() .'/js/jquery.watermark.js',array('jquery'));	
		wp_enqueue_script('loading', get_template_directory_uri() .'/js/loading.js',array('jquery'));
	}
	if(is_home()){
		wp_enqueue_script('jquery.transform2d', get_template_directory_uri() .'/js/jquery.transform2d.js',array('jquery'));
		wp_enqueue_script('jquery.jparallax.min', get_template_directory_uri() .'/js/jquery.jparallax.min.js',array('jquery'));
		wp_enqueue_script('loading', get_template_directory_uri() .'/js/loading.js',array('jquery'));		
	}
	if(is_page()){
		wp_enqueue_script('jquery.mCustomScrollbar.concat.min', get_template_directory_uri() .'/js/jquery.mCustomScrollbar.concat.min.js',array('jquery'));		
	}
	
	//wp_enqueue_script('bigc', get_template_directory_uri() .'/js/bigc.js',array('jquery','jquery-ui-core'));
	
	/*
	  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
	if(is_plugin_active('bigc-kool-idol/bigc-kool-idol.php') && is_single())	
		wp_enqueue_script('jvote', get_template_directory_uri() . '/js/jvote/jVote.js');
		*/

}
function style_include(){
	wp_enqueue_style('style',get_template_directory_uri() . '/style.css');	
	wp_enqueue_style('font',get_template_directory_uri() . '/css/font.css');
	wp_enqueue_style('reset',get_template_directory_uri() . '/css/reset.css');
	wp_enqueue_style('jquery.mCustomScrollbar',get_template_directory_uri() . '/css/jquery.mCustomScrollbar.css');
}
//=================== excerpt setting =========
function custom_excerpt_length( $length ) {
	return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
function new_excerpt_more( $more ) {
	return '...';
}
add_filter('excerpt_more', 'new_excerpt_more');

//================ tinymce config ===============
function mytheme_tinymce_config( $init ) {
 $valid_iframe = 'iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]';
 if ( isset( $init['extended_valid_elements'] ) ) {
  $init['extended_valid_elements'] .= ',' . $valid_iframe;
 } else {
  $init['extended_valid_elements'] = $valid_iframe;
 }
 return $init;
}
add_filter('tiny_mce_before_init', 'mytheme_tinymce_config');
add_action( 'wp_enqueue_scripts', 'script_include' );
add_action( 'wp_enqueue_scripts', 'style_include' );
add_action( 'init', 'register_my_menu' );
?>